package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateExtUtils;
import com.ruoyi.system.domain.WatermarkConfig;
import com.ruoyi.system.mapper.WatermarkConfigMapper;
import com.ruoyi.system.service.IWatermarkConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 水印设置Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-03
 */
@Service
public class WatermarkConfigServiceImpl implements IWatermarkConfigService
{
    @Autowired
    private WatermarkConfigMapper watermarkConfigMapper;

    /**
     * 查询水印设置
     *
     * @param id 水印设置ID
     * @return 水印设置
     */
    @Override
    public WatermarkConfig selectWatermarkConfigById(Long id)
    {
        return watermarkConfigMapper.selectWatermarkConfigById(id);
    }

    /**
     * 查询水印设置列表
     *
     * @param watermarkConfig 水印设置
     * @return 水印设置
     */
    @Override
    public List<WatermarkConfig> selectWatermarkConfigList(WatermarkConfig watermarkConfig)
    {
        return watermarkConfigMapper.selectWatermarkConfigList(watermarkConfig);
    }

    @Override
    public TableDataInfo<WatermarkConfig> selectPageWatermarkConfigList(WatermarkConfig watermarkConfig, PageQuery pageQuery) {
        Page<WatermarkConfig> watermarkConfigPage = watermarkConfigMapper.selectJoinPage(pageQuery.build(), WatermarkConfig.class, this.buildQueryWrapper(watermarkConfig));
        //Page<FileBorrowingRegistration> page = fileBorrowingRegistrationMapper.selectFileBorrowingRegistrationList(this.buildQueryWrapper(fileBorrowingRegistration));
        return TableDataInfo.build(watermarkConfigPage);
    }

    private MPJLambdaWrapper<WatermarkConfig> buildQueryWrapper(WatermarkConfig watermarkConfig) {
        MPJLambdaWrapper<WatermarkConfig> watermarkConfigJoinLambdaWrapper = new MPJLambdaWrapper<WatermarkConfig>();

        return watermarkConfigJoinLambdaWrapper;
    }

    /**
     * 新增水印设置
     *
     * @param watermarkConfig 水印设置
     * @return 结果
     */
    @Override
    public int insertWatermarkConfig(WatermarkConfig watermarkConfig)
    {
        watermarkConfig.setCreateTime(DateExtUtils.getNowDate());
        return watermarkConfigMapper.insertWatermarkConfig(watermarkConfig);
    }

    /**
     * 修改水印设置
     *
     * @param watermarkConfig 水印设置
     * @return 结果
     */
    @Override
    public int updateWatermarkConfig(WatermarkConfig watermarkConfig)
    {
        watermarkConfig.setUpdateTime(DateExtUtils.getNowDate());
        return watermarkConfigMapper.updateWatermarkConfig(watermarkConfig);
    }

    /**
     * 批量删除水印设置
     *
     * @param ids 需要删除的水印设置ID
     * @return 结果
     */
    @Override
    public int deleteWatermarkConfigByIds(Long[] ids)
    {
        return watermarkConfigMapper.deleteWatermarkConfigByIds(ids);
    }

    /**
     * 删除水印设置信息
     *
     * @param id 水印设置ID
     * @return 结果
     */
    @Override
    public int deleteWatermarkConfigById(Long id)
    {
        return watermarkConfigMapper.deleteWatermarkConfigById(id);
    }
}
